set more off

use dataset35k, clear

gen anyfines = lfinesand > 0

*** covariates ***

local X1 totalrevownsourcespcp pcttotaltax pcttotalig
local X2 lpopulation popdensity incomepcp pctba pct65plus H pcthisp herf pctforeign
local X3 crimepcp totalpolicepcp dem ngovspcp netmigration 

local X `X1' `X2' `X3' `X4'

foreach x in `X' pctblack {
	su `x'
	replace `x' = (`x' - r(min)) / (r(max) - r(min))
	drop if mi(`x')
}


eststo clear

gen insample = spendsonpoliceorcourts == 1 & population2010 >= 2500
eststo, title("Sample inclusion"): reg insample pctblack `X1' `X2' `X3', robust

keep if insample == 1
foreach x in `X' pctblack {
	su `x'
	replace `x' = (`x' - r(min)) / (r(max) - r(min))
	drop if mi(`x')
}

eststo, title("Any fines revenue"): reg anyfines pctblack `X1' `X2' `X3' if insample == 1, robust

label variable pctblack "Percent black population"

#delimit;

esttab 
	using "tableA1.tex"
	,
		replace 
		label
		booktabs
		cells(b(fmt(2) star) se(par))
		collabels(none)
		mtitles
		width(\textwidth)
		stats(
			N r2
			,
				label("Sample size" "R-squared")
				fmt(%20.0fc %20.02fc)
		)	
		compress
		;
#delimit cr


esttab, keep(pctblack) se stats(mydiff mydiffse N r2)
